﻿@using LKVMLMADMIN.Models;
@using PagedList.Mvc;
@using System.Globalization;
@using LKVMLMLib;

@{
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";

}

@using (Html.BeginForm("DoanhSo", "Order", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-inline" }))
{  
    <div id="wrapper">
        <div class="clear-fix"></div>
        <div class="row">
            <div style=" min-height: 110px; padding-left: 30px; ">             
                    <h3 class="page-header">Danh sách đơn hàng</h3>
                    <span>@ViewBag.Msg</span>
                    <input type="text" name="Username" class="form-control">         
                @Html.DropDownList("SearchType", new SelectList(
                       new List<Object>{
                       new { value ="Username" , text = "Username"},
                       new { value ="Mã Đơn hàng" , text = "Mã Đơn hàng"},
                    },
                  "value",
                  "text",
                 null), new { @class = "form-control" })
                @Html.DropDownList("status", new SelectList(
                       new List<Object>{
                       new { value =0 , text = "Tất cả"},
                       new { value =1 , text = "Kích hoạt"},
                         new { value =2 , text = "Chưa kích hoạt"}
                    },
                  "value",
                  "text",
                 null), new { @class = "combobox" })
                @{ DateTime a =new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                   DateTime b =new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1);
                 }

                <input type="text" name="Fromdate" class="form-control inputBox" value="@a">
                <input type="text" name="Todate" class="form-control inputBox" value="@b">
                <button type="submit" class="btn_submit btn btn-default">Tìm kiếm</button>         
                <a href="@Url.Action("Addorder", "Order")" class="btn_submit btn btn-default">Thêm đơn hàng</a>     
            </div>
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel-body">
                    <div class="dataTable_wrapper">
                        <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                            <thead>
                                <tr style="font-family:'Times New Roman'">
                                    <th>STT</th>
                                    <th>ID Đơn hàng</th>
                                    <th>UserName</th>
                                    <th>Họ tên</th>
                                    <th>Mã đơn hàng</th>
                                    <th>Doanh số</th>
                                    <th>Ngày tạo</th>
                                    <th>Gói mua</th>
                                    <th>Kích hoạt</th>
                                    <th>Chọn</th>
                                </tr>
                            </thead>
                            <tbody style="font-family:'Times New Roman'">
                                @{int j = 0;}
                                @foreach (var item in ViewBag.DoanhSo)
                                {

                                    j++;
                                    <tr>
                                        <td>@j</td>
                                        <td>@item.ID</td>
                                        <td>@item.STT</td>
                                        <td>@item.HoTen</td>
                                        <td>@item.ID_OrDer</td>
                                        <td>@item.Amount</td>
                                        <td>@String.Format("{0:d/MM/yyyy}", item.CreateDate)</td>
                                        <td>@item.Package_Name</td>   
                                        @if(item.NewAction == false)
                                        {                              
                                            <td>
                                                @item.NewAction
                                                @*<a class="doactive" href="@Url.Action("ActiveOrder", "Order", new { orderId = @item.ID })">@item.NewAction</a>*@
                                            </td>
                                        }
                                        else
                                        {
                                            <td>@item.NewAction</td>
                                        }
                                        <td><a class="confirmation" href="@Url.Action("DeleteOrder", "Order", new { id = item.ID} )">Delete</a></td>
                                    </tr>
                                }

                            </tbody>
                        </table>
                    </div>
                    <div>
                        <strong class="pull-right ">
                            Tổng tiền:&nbsp<i class="mone">
                                @ViewBag.tongtien
                            </i>  Bitcoin
                        </strong>
                    </div>
                    @*<a href="@Url.Action("Addorder", "Order")" class="btn_submit btn btn-default">Thêm đơn hàng</a>*@          
                </div>
            </div>
            <!-- /.panel -->
        </div>
    </div>
    <div class="dataTables_paginate paging_full_numbers pull-right" id="dyntable_paginate">
        @Html.PagedListPager((PagedList.IPagedList)Model, page => Url.Action("DoanhSo", new { page, bydate = ViewBag.ByDate, Fromdate = ViewBag.DateFrom, Todate = ViewBag.Todate }))
    </div>   
        <script src="~/Scripts/fm.datetator-fo.jquery.js"></script>
        <link href="~/Scripts/fm.datetator.jquery.css" rel="stylesheet" />
        <script src="~/Scripts/fm.datetator.jquery.js"></script>
        <script type="text/javascript">
            $('.inputBox').datetator();
            $('.doactive').on('click', function () {
                return confirm('bạn có chắc chắn muốn kích hoạt ?');
            });
            $('.confirmation').on('click', function () {
                return confirm('bạn có chắc chắn muốn xóa?');
            });
        </script>
   
}